using System;
using System.Collections;
using System.Data;
using System.Windows.Forms;
using ctsu.Admin.Forms;
using ctsu.BaseForms;
using ctsu.Security;
//using ctsu.Data;
using Syncfusion.Windows.Forms.Tools;

namespace ctsu.Admin.BusLogic
{
	public class BLFormProtocolVisitOutPatientDialogImpl : BLFormProtocolVisitOutPatientImpl
	{
		public BLFormProtocolVisitOutPatientDialogImpl(FormMain formMain, FormBase form, FormInfoBase formInfo, DataTable tableSchema, Permission formSecurity, Hashtable configData)
			: base(formMain, form, formInfo, tableSchema, formSecurity, configData)
		{

		}

		public override bool Initialize()
		{
			if (base.Initialize())
			{
				this._form.btnGrid.Visible = false;
				this._form.btnRemove.Visible = false;
				this._form.btnSearch.Visible = false;
				this._form.btnNew.Visible = false;
				this._form.btnEdit.Visible = false;
				this._form.chkGridTracking.Visible = false;
				this.New();
				return true;
			}
			return false;
		}

		public override void Cancel()
		{
			this._form.DialogResult = DialogResult.Cancel;
			base.Cancel();
		}

		public override void Exit()
		{
			this._form.DialogResult = DialogResult.Cancel;
			base.Exit();
		}

		public override bool Save()
		{
			if (base.Save())
			{
				//TODO - error protect
				VisitInfo vi = new VisitInfo();
				vi.ID = this.CurrentPrimaryID;
				vi.PatientID = Convert.ToInt32(this._patient.Text);
				vi.ProtocolID = Convert.ToInt32(this._protocol.Text);
				//vi.//SPID = Convert.ToInt32(this._spid.Text);
				FieldContext fc = (FieldContext)this._fcManager.Item("VisitDate");
				vi.VisitDate = ((DateTimePickerAdv)fc.Control).Value;

				this._form.DialogReturnObject = vi;
				this._form.DialogResult = DialogResult.OK;
				this._form.CurrentPrimaryID = this.CurrentPrimaryID;
				return true;
			}
			return false;
		}
	}
}
